<?php

require_once 'common/conn.php';
if (isset($_GET['start'])) {
    $start = $_GET['start'];
} else {
    $start = 0;
}
if (isset($_GET['limit'])) {
    $limit = $_GET['limit'];
}

if (isset($_GET['usercode'])) {
    $usercode = $_GET['usercode'];
}

$data = array();
if (is_numeric($start) && is_numeric($limit)) {
    $db = new DBC();
    // $sql = "SELECT usercode,flashcode,type,downloadTime FROM t_device_product  WHERE usercode = '" . $usercode . "'  LIMIT " . $num . "," . $count;

    $sql = "SELECT DISTINCT m.flashcode AS code,m.name,m.url,m.version,m.price,m.goodprice,m.promotion,m.imageURL,m.type1 AS type,1 AS isDownload FROM t_music m "
            . "WHERE m.flashcode IN (SELECT flashcode FROM t_device_product WHERE type = 4 AND usercode = '" . $usercode
            . "') AND m.status = 1 ORDER BY m.num LIMIT " . $start . "," . $limit;
    $data = $db->fetchData($sql);
}
echo json_encode($data);
?>